// #include<bits/stdc++.h>
// using namespace std;
#include "stdio.h"
#include "stdlib.h"
#include "math.h"

#define min(x,y) (x>y?y:x)
#define N 20010
void sort(int a[N],long len);

int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    // vector<int> a(n),b(m);
    int a[N] ={0};
    int b[N] ={0};
    for(int i=0;i<n;++i) //cin>>a[i];
    {
        scanf("%d",&a[i]);
    }
    for(int j=0;j<m;++j) //cin>>b[j];
    {
        scanf("%d",&b[j]);
    }
    sort(a,n);
    sort(b,m); //排序

    int ans = 0x3f3f3f3f;
    int x=0,y=0;
    while((x<n)&&(y<m)){ //两个升序列比较
         ans = min(ans,abs(a[x]-b[y]));
         if (a[x] > b[y])y++;
		else x++;
    }
    printf("%d\n",ans);
}

void sort(int a[N],long len)
{
    int T = 0;
    int i = 0;
    int m = len-1;//冒泡的上限
    int not_order_flag = 1;//走一趟发现不需要交换，即没有排序完成的flag
    while (m>0 && not_order_flag == 1 ){
        not_order_flag = 0;//默认排序完成
        for(i=0;i<m;i++){
            if(abs(a[i])>abs(a[i+1])){
                not_order_flag = 1; //需要交换说明还没有排序完成
                // printf("a[i] = %d,a[i+1]=%d",a[i],a[i+1]);
                T = a[i];
                a[i] = a[i+1];
                a[i+1] = T;
            }
        }
        m--;
    }
}